﻿
using System;

namespace DatabaseCore.Modal
{

    /// <summary>
    /// 数据库查询结果
    /// </summary>
    public class DBResult
    {

        public dynamic Data { get; set; }

        public string TableName { get; set; }

        public string Sql { get; set; }

        public int Page { get; set; }

        public int Size { get; set; }

        public string Message { get; set; }

        /// <summary>
        /// 总条数
        /// 
        /// 当操作类型是如下时：那么这个属性的值就是受影响的行数
        ///         "INSERT"        
        ///         "UPDATE"
        ///         "DELETE"
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPage { get; set; }

        public DBResult() { }

        public DBResult(object _Data)
        {
            this.Data = _Data;
        }

        public DBResult(object _Data, int _Count, int _Page, int _Size)
        {
            double a = _Count / _Size;
            this.Data = _Data;
            this.TotalCount = _Count;
            this.TotalPage = _Count % _Size == 0 ? int.Parse(a.ToString()) : int.Parse((Math.Floor(a) + 1).ToString());
        }
    }
}
